import api from '../config/api'

import { request, showToast } from '../utils/util'
import {BaseUrl} from '../config/api'

/** 登录 */
export function LoginRequest (data,isLoading) {
  return new Promise((resolve,reject)=>{
    request(
      BaseUrl + api.login,
      data,
      'POST',
      isLoading
    ).then(res=> {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

/** 我的成绩查询 */
export function GetStudentgrades (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getStudentgrades + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }

  /** 我的成绩查询可修改次数 */
export function GetStudentCslist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getStudentCslist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }
  

  /** 我的成绩新增 */
export function GetStudentgradesAdd (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getStudentgradesAdd,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }



/** 距离高考天数 */
export function GetCountdown (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getCountdown,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }


/** 查院校 */
export function GetSchoolList (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getSchoolList + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 院校详情 */
export function GetSchoolDetail (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getSchoolDetail,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 查专业 */
export function GetCleanQue (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getCleanQue + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 查专业搜索 */
export function GetMajorSomeList (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getMajorSomeList + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 专业详情 */
export function GetMajorDtl (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getMajorDtl,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 查职业 */
export function GetCareerList (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getCareerList + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 职业详情 */
export function GetCareerDtl (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getCareerDtl,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


/** 院校排名 */
export function GetSchoolRankListUrl (data,type,isLoading) {
    return new Promise((resolve,reject)=>{
        console.log(type)
      let url =  urlString(type)
      console.log(url)
      request(
        url + data,
        {},
        'get',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }

  const urlString = function (type) {
    // 0 校友会 1武书连 2科软 3QS 4USNews
if (type == 0)  return BaseUrl + api.getSchoolFriend;
if (type == 1)  return BaseUrl + api.getSchoolShulian;
if (type == 2)  return BaseUrl + api.getSchoolKeRuan;
if (type == 3)  return BaseUrl + api.getSchoolQsRuan;
if (type == 4)  return BaseUrl + api.getSchoolUsnewsList;
}


/** 首页列表 */
export function GetHomeList (data,type,isLoading) {
    return new Promise((resolve,reject)=>{
        console.log(type)
      let url =  homeUrlString(type)
      console.log(url)
      request(
        url + data,
        {},
        'get',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }

  const homeUrlString = function (type) {
    // 0 院校排行 1报考专家 2高考资讯 3服务介绍
if (type == 0)  return BaseUrl + api.getSchoolList;
if (type == 1)  return BaseUrl + api.getHightExpertList;
if (type == 2)  return BaseUrl + api.getHightNewsList;
if (type == 3)  return BaseUrl + api.getHightServiceList;
}



/** 高考资讯详情 */
export function GetHightNewsDtl (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHightNewsDtl,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 服务介绍详情 */
export function GetHightServiceDtl (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHightServiceDtl,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 招生简章详情 */
export function GetSchoolRulesDtl (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getSchoolRulesDtl,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 资讯分类 */
export function GetHightNewsType (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHightNewsType + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 收藏 */
export function GetCollect (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getCollect,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 收藏列表 */
export function GetCollectList (data,type,isLoading) {
    return new Promise((resolve,reject)=>{
        console.log(type)
      let url =  collectUrlString(type)
      console.log(url)
      request(
        url + data,
        {},
        'get',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }

  const collectUrlString = function (type) {
    // 0 收藏院校 1收藏专业
if (type == 0)  return BaseUrl + api.getSchoolCollectList;
if (type == 1)  return BaseUrl + api.getMajorCollectList;
}

/** 取消收藏 */
export function GetCancelCollect (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getCancelCollect,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 院校加入对比 */
export function GetContrastAdd (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getContrastAdd,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 院校取消对比 */
export function GetContrastDel (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getContrastDel,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 院校对比列表 */
export function GetContrastList (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getContrastList + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 院校对比详情 */
export function GetContrastDetail (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getContrastDetail,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 批次线列表 */
export function GetPclineList (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getPclineList,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 开关 */
export function GetSwitchconfig (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getSwitchconfig,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


/** 理科一分一段列表 */
export function GetLkyfd (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getLkyfd + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 文科一分一段列表 */
export function GetWkyfd (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getWkyfd + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 一分一段获取年份 */
export function GetFdyearlist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getFdyearlist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


/** 根据分数获取理科位次 */
export function GetLkFdbyscore (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getLkFdbyscore,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 根据分数获取文科位次 */
export function GetWkFdbyscore (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getWkFdbyscore,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


/** 招生计划 */
export function GetZsjhlist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getZsjhlist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 专家预约 */
export function GetExpertreserveAdd (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getExpertreserveAdd,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}



// 测评试题列表
export function GetTesttypelist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getTesttypelist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 测评试题列表
export function GetQuelist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getQuelist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 提交测评结果
export function GetTestresultSubmit (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getTestresultSubmit,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 测评结果查询
export function GetTestresultInquire (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getTestresultInquire + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// MBTI测评结果查询
export function GetTestmbtiList (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getTestmbtiList + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 测评结果性格查询
export function GetTestresultInquireCharacter (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getTestresultInquireCharacter + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 选科要求
export function GetXklist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getXklist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 批次要求
export function GetPclist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getPclist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 卡密激活
export function GetDoActivate (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getDoActivate,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


/** 富文本 */
export function GetRich (data,type,isLoading) {
    return new Promise((resolve,reject)=>{
        console.log(type)
      let url =  richUrlString(type)
      console.log(url)
      request(
        url + data,
        {},
        'get',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }

  const richUrlString = function (type) {
    // 0 帮助中心 1关于我们 2用户协议
if (type == 0)  return BaseUrl + api.getHelplist;
if (type == 1)  return BaseUrl + api.getAboutlist;
if (type == 2)  return BaseUrl + api.getProtocollist;
}


// 更新用户头像昵称
export function GetStudentinfoAdd (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getStudentinfoAdd,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 智能填报城市列表
export function GetStudentgradesProvlist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getStudentgradesProvlist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 智能填报弹框数据
export function GetStudentgradesFirsttotal (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getStudentgradesFirsttotal,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

/** 富文本 */
export function GetStudentGradesList (data,type,isLoading) {
    return new Promise((resolve,reject)=>{
        console.log(type)
      let url =  studentUrlString(type)
      console.log(url)
      request(
        url + data,
        {},
        'get',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }

  const studentUrlString = function (type) {
    // 0 帮助中心 1关于我们 2用户协议
    if (type == 0)  return BaseUrl + api.getStudentgradesCclist;
    if (type == 2)  return BaseUrl + api.getStudentgradesShlist;
    if (type == 1)  return BaseUrl + api.getStudentgradesWtlist;
}


// 智能填报汇总
export function GetStudentgradesTablist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getStudentgradesTablist,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}



// 智能填报专业弹框数据
export function GetStudentgradesZyzadd (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getStudentgradesZyzadd,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 智能填报专业填报
export function GetHewillAdd (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHewillAdd,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 智能填报专业列表
export function GetHewillList (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHewillList + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 智能填报专业上移下移
export function GetHewilldtlZyzmove (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHewilldtlZyzmove,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 智能填报专业删除
export function GetHewilldtlZydel (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHewilldtlZydel,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 智能填报专业组上移下移
export function GetHewillZyzmove (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHewillZyzmove,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 智能填报专业组删除
export function GetHewillZyzdel (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHewillZyzdel,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 智能填报调剂
export function GetHewillUpdate (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHewillUpdate,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 我的志愿表
export function GetHewillMyzylist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHewillMyzylist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}



// 查询用户信息
export function GetByOpenId (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getByOpenId,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 问题反馈
export function GetQuestionAdd (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getQuestionAdd,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 院校详情历史分数
export function GetHislist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHislist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}


// 查询高考时间
export function GetHightDate (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getHightDate + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 删除全部专业组
export function GetZyzdelall (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getZyzdelall,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 选科
export function GetXkjhbk (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getXkjhbk + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 选科专业列表或 根据院校查专业
export function GetMajorlist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getMajorlist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 选科院校列表或 根据专业查院校
export function GetXkjhbkSchoollist (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getXkjhbkSchoollist + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 选科根据专业查院校
export function GetSchoolByMajor (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getSchoolByMajor + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 选科根据院校查专业
export function GetMajorBySchool (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getMajorBySchool + data,
        {},
        'GET',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

// 发送PDF到邮箱
export function GetSendEmailPDF (data,isLoading) {
    return new Promise((resolve,reject)=>{
      request(
        BaseUrl + api.getSendEmailPDF,
        data,
        'POST',
        isLoading
      ).then(res=> {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
}

